﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SWDataDB.Models;
using SWDataDB.BLL;
using SWDataDB.DAL;
using System.Data;



public partial class AdminManage_Edit_UTILEdit : System.Web.UI.Page
{

    public string utid = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        utid = Request["utid"];
        bind();
    }


    private void bind()
    {
        UTILInfo xgquery = new UTILInfo();
        int XGID = Convert.ToInt32(utid);
        DataSet ds = xgquery.SelectInfoByID(XGID);
        DataRowView dv = ds.Tables[0].DefaultView[0];

        
        
      
        ZL_FILE_ID.Text = Convert.ToString(dv.Row["ZL_FILE_ID"]);
         
        SW_TYPE.Text = Convert.ToString(dv.Row["SW_TYPE"]);
        SW_NUM.Text = Convert.ToString(dv.Row["SW_NUM"]);
        COL_NAME.Text = Convert.ToString(dv.Row["COL_NAME"]);
        COL_DATE.Text = Convert.ToString(dv.Row["COL_DATE"]);


         


        //从著录表中读取title
        ZLInfo ZLFILEID = new ZLInfo();
        ZL_TBL zl = ZLFILEID.SelectZLInfoByID(dv.Row["ZL_FILE_ID"].ToString());
         
        FileTitle.Text = zl.O_TITLE;


    }


    protected void submit_Click(object sender, EventArgs e)
    {
        UTIL_TBL xg_info = new UTIL_TBL();
        UTILInfo kc_in = new UTILInfo();

        xg_info.O_ZL_FILE_ID = this.ZL_FILE_ID.Text;
        xg_info.O_SW_TYPE = Request.Form["SW_TYPE"];
        xg_info.O_SW_NUM =Convert.ToInt16( Request.Form["SW_NUM"]);
        xg_info.O_COL_NAME = Request.Form["COL_NAME"];

        xg_info.O_COL_DATE = Request.Form["COL_DATE"];

        xg_info.O_ID = int.Parse(utid);

        if (kc_in.UpdateUtilInfo(xg_info) == 1)
        {
            bind();
            Response.Write("<script language=javascript>alert('更新成功！');location='../Manage/UTILManage.aspx'</script>");
            //Response.Redirect("ZLManage.aspx");
        }
        else
        {
            Response.Write("<script language=javascript>alert('更新失败！');location='../Manage/UTILManage.aspx'</script>");
        }
    }
}